<template>  
<div class="bg-image">
  <div class="profile-page">
    <div class="content-wrapper">
      <div class="content-box">
        <div class="profile-features">
          <button 
            @click="checkLoginAndExecute(showPersonalMuseum)" 
            class="feature-button animated-button"
          >
            个人博物馆
          </button>
          <button 
            @click="checkLoginAndExecute(showCollectedQuestions)" 
            class="feature-button animated-button"
          >
            收藏题集
          </button>
          <button 
            @click="checkLoginAndExecute(showCollectedNews)" 
            class="feature-button animated-button"
          >
            收藏动态
          </button>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
export default {
  name: 'Profile',
  props: {
    isLoggedIn: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    userIsLoggedIn() {
      return this.isLoggedIn;
    }
  },
  methods: {
    checkLoginAndExecute(func) {
      if (this.isLoggedIn) {
        func();
      } else {
        alert('请先注册或登录以使用此功能');
      }
    },
    showPersonalMuseum() {
      // 实现个人博物馆的逻辑
      console.log('显示个人博物馆');
      this.$router.push({ name: 'CollectedArtifacts' });
    },
    showCollectedQuestions() {
      // 使用Vue Router跳转到收藏题集页面
      this.$router.push({ name: 'CollectedQuestions' });
    },
    showCollectedNews() {
      this.$router.push({ name: 'CollectedNews' });
    },
    goBack() {
      this.$router.go(-1); // 返回上一页
    }
  }
};
</script>

<style scoped>
.bg-image {
  background-image: url('@/assets/m20.jpg'); 
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
}

.bg-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4); /* 调暗程度可以通过调整 alpha 值来控制 */
  z-index: 1;
}
/* 页面内容 */
.profile-page {
  width: 100%;
  min-height: 83vh;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-top: 10%;
}

.content-wrapper {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.content-box {
  display: flex;
  justify-content: flex-start; /* 将内容靠左对齐 */
  align-items: center;
  width: 100%;
  max-width: 1200px;
}

.profile-features {
  display: flex;
  flex-direction: column; /* 按钮垂直排列 */
  align-items: flex-start; /* 按钮靠左对齐 */
  gap: 20px;
  position: relative;
  z-index: 2; /* 确保按钮位于覆盖层之上 */
}

/* 按钮样式 */
.feature-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background-color: #754f2b; 
  color: white;
  border: none;
  padding: 15px 80px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  font-size: 18px;
  font-weight: bold;
  width: 100%;
  max-width: 300px;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 2vw;
}

.feature-button:hover {
  color: rgb(18, 19, 18);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.feature-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  transition: all 0.4s ease;
}

.feature-button:hover::before {
  left: 100%;
}

.feature-button:active {
  background-color: #8A670C; /* 更深的古铜色 */
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* 响应式设计 */
@media screen and (max-width: 768px) {
  .content-box {
    padding: 20px;
  }

  .feature-button {
    width: 90%;
    max-width: 250px;
  }
}

@media screen and (max-width: 480px) {
  .feature-button {
    font-size: 16px;
    padding: 12px 24px;
  }
}
</style>
